*********************************************************************
*This file cleans IT capital investment data, routine and offshoring*
*********************************************************************

**measure using total employment in 1970**
use "$clean_data_lmarket/czone_1970_emp_by_ifr19.dta", replace 

gen manufacturing=1
replace manufacturing=0 if industry_ifr19=="agriculture"
replace manufacturing=0 if industry_ifr19=="mining"
replace manufacturing=0 if industry_ifr19=="construction"
replace manufacturing=0 if industry_ifr19=="utilities"
replace manufacturing=0 if industry_ifr19=="research"
replace manufacturing=0 if industry_ifr19=="services"

*merge: capital
merge m:1 industry_ifr19 using "$contributed_data/capital_ifr19", assert(3) nogenerate

*logarithmic versions*
gen expo_capital_1990_2007=100*(ln(capital_qty_2007)-ln(capital_qty_1990))
gen expo_itcapital_1990_2007=100*(ln(itcapital_qty_2007)-ln(itcapital_qty_1990))

gen expo_capital_y1990=100*(ln(capital_qty_2000)-ln(capital_qty_1990))*0.7
gen expo_itcapital_y1990=100*(ln(itcapital_qty_2000)-ln(itcapital_qty_1990))*0.7

gen expo_capital_y2000=100*(ln(capital_qty_2007)-ln(capital_qty_2000))
gen expo_itcapital_y2000=100*(ln(itcapital_qty_2007)-ln(itcapital_qty_2000))

*merge: offshorability and routine jobs exposure
merge m:1 industry_ifr19 using "$contributed_data/industry_census_xs_ifr19", assert(3) nogenerate

gen expo_cond_task_routine=100*task_p66_RTIa if manufacturing==1
gen expo_task_routine=100*task_p66_RTIa

gen expo_cond_task_offshore=100*task_p66_offshore if manufacturing==1
gen expo_task_offshore=100*task_p66_offshore

collapse (mean) expo_* [w=emppriv], by(czone)
save "$clean_data_automation/expo_trends.dta", replace

